package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import proxy.ProxyConcreto;

/**
 * Servlet implementation class ListaComparativa
 */
public class ListaComparativa extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ListaComparativa() {
        super();
        System.setProperty("java.security.policy", "C:\\Proyecto y Documentacion\\src-final\\clienteWeb\\src\\client.policy");
		System.setSecurityManager(new SecurityManager());
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String codigo = request.getParameter("txtCodigo");
		String descripcion = request.getParameter("txtDesc");
		String marca = request.getParameter("txtMarca");
		String pais = request.getParameter("txtPais");
		
		ProxyConcreto p = new ProxyConcreto();
		
		List<Object[]> lista = p.buscarListaComparativa(codigo, descripcion, marca, pais);
	
		ServletContext sc = getServletContext();
		
		sc.setAttribute("listaComparativa", lista);
		response.sendRedirect("mostrarLista.jsp");
	}

}
